﻿<?xml version="1.0" encoding="utf-8" ?>

<cls:class
	name="InternetConnectionPacket"
	type="http://metalx.org/Network/Internet/InternetConnectionPacket"
	xmlns="http://metalx.org/Program"
	xmlns:cls="http://metalx.org/Class"
	xmlns:obj="http://metalx.org/i386/Functions/Object"
	xmlns:int="http://metalx.org/i386/Functions/Integer"
	xmlns:hex="http://metalx.org/i386/Functions/Hexadecimal"
	xmlns:lst="http://metalx.org/i386/Functions/List"
	xmlns:net="http://metalx.org/i386/Functions/Network"
	xmlns:str="http://metalx.org/i386/Functions/String"
	xmlns:mm="http://metalx.org/i386/Functions/MemoryManager"
	xmlns:clsf="http://metalx.org/i386/Functions/Class"
	xmlns:pcif="http://metalx.org/i386/Functions/Pci"
	xmlns:var="http://metalx.org/Variable"
	xmlns:sys="http://metalx.org/i386/Functions/System"
	xmlns:cat="http://metalx.org/i386/Functions/Catalog"
	xmlns:asc="http://metalx.org/Ansi/Ascii"
	xmlns:pci="http://metalx.org/Pc/Pci/Ports"
	xmlns:cfg="http://metalx.org/Pc/Pci/Configuration"
	xmlns:ari="http://metalx.org/Intel/80386/Arithmetic"
	xmlns:math="http://metalx.org/Intel/80386/Math"
	xmlns:shift="http://metalx.org/Intel/80386/Shift"
	xmlns:cpu="http://metalx.org/Intel/80386/Operators"
	xmlns:op="http://metalx.org/Intel/80386/Operands">

	<cls:field name="InternetPacket" type="http://metalx.org/Network/Internet/InternetPacket" offset="0"/>
	<cls:field name="NetworkPacket" type="http://metalx.org/Network/NetworkPacket" offset="0"/>

	<cls:method name="GetSource" type="http://metalx.org/Short">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyImmediateToAX/>
		<int>0</int>

		<cpu:Operand16/>
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddressPlusImmediate8/>
		<byte>34</byte>

		<cpu:ExchangeOperandWithRegister8/>
		<op:AL-AHRegister/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetDestination" type="http://metalx.org/Short">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyImmediateToAX/>
		<int>0</int>

		<cpu:Operand16/>
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddressPlusImmediate8/>
		<byte>36</byte>

		<cpu:ExchangeOperandWithRegister8/>
		<op:AL-AHRegister/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetSequence" type="http://metalx.org/Integer">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>38</byte>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>8</byte>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>39</byte>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>8</byte>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>40</byte>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>8</byte>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>41</byte>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetAcknowledge" type="http://metalx.org/Integer">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>42</byte>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>8</byte>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>43</byte>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>8</byte>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>44</byte>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>8</byte>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>45</byte>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetWindow" type="http://metalx.org/Short">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyImmediateToAX/>
		<int>0</int>

		<cpu:Operand16/>
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddressPlusImmediate8/>
		<byte>48</byte>

		<cpu:ExchangeOperandWithRegister8/>
		<op:AL-AHRegister/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetChecksum" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyImmediateToAX/>
		<int>0</int>

		<cpu:Operand16/>
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddressPlusImmediate8/>
		<byte>50</byte>

		<cpu:ExchangeOperandWithRegister8/>
		<op:AL-AHRegister/>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="CalculateChecksum" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<net:CalculateTcpChecksum/>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="RecalculateChecksum" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:PushSIToStack/>

		<cpu:MathImmediate8ToOperandFunction/>
		<math:AddToSIRegister/>
		<byte>14</byte>

		<!--Get IP Header Length-->
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:AndAXWithImmediate/>
		<hex>0000000f</hex>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>2</byte>

		<cpu:AddRegisterToOperand/>
		<op:AX-SIRegister/>

		<cpu:Operand16/>
		<cpu:CopyImmediateToOperandFunction/>
		<imm:CopyImmediateToSIAddressPlusImmediate8 xmlns:imm="http://metalx.org/Intel/80386/Immediate"/>
		<byte>16</byte>
		<hex>0000</hex>

		<cpu:PullSIFromStack/>

		<net:CalculateTcpChecksum/>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetPointer" type="http://metalx.org/Short">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyImmediateToAX/>
		<int>0</int>

		<cpu:Operand16/>
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddressPlusImmediate8/>
		<byte>52</byte>

		<cpu:ExchangeOperandWithRegister8/>
		<op:AL-AHRegister/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetHeaderLength" type="http://metalx.org/Integer">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:MathImmediate8ToOperandFunction/>
		<math:AddToSIRegister/>
		<byte>14</byte>

		<!--Get IP Length-->
		<cpu:CopyImmediateToAX/>
		<int>0</int>

		<cpu:Operand16/>
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddressPlusImmediate8/>
		<byte>2</byte>

		<cpu:ExchangeOperandWithRegister8/>
		<op:AL-AHRegister/>

		<cpu:CopyRegisterToOperand/>
		<op:AX-CXRegister/>

		<cpu:CopyRegisterToOperand/>
		<op:AX-BXRegister/>

		<!--Get IP Header Length-->
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:AndAXWithImmediate/>
		<hex>0000000f</hex>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>2</byte>

		<cpu:SubtractRegisterFromOperand/>
		<op:AX-CXRegister/>

		<cpu:AddRegisterToOperand/>
		<op:AX-SIRegister/>

		<!--Get TCP Header Length-->
		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>12</byte>

		<cpu:ShiftRegisterByImmediateFunction8/>
		<shift:ShiftALRegisterRight/>
		<byte>4</byte>

		<cpu:AndAXWithImmediate/>
		<hex>0000000f</hex>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetFlags" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>47</byte>

		<cpu:AndAXWithImmediate/>
		<hex>000000ff</hex>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetOptions" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddressPlusImmediate8/>
		<byte>54</byte>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetMessageLength" type="http://metalx.org/Integer">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:MathImmediate8ToOperandFunction/>
		<math:AddToSIRegister/>
		<byte>14</byte>

		<!--Get IP Length-->
		<cpu:CopyImmediateToAX/>
		<int>0</int>

		<cpu:Operand16/>
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddressPlusImmediate8/>
		<byte>2</byte>

		<cpu:ExchangeOperandWithRegister8/>
		<op:AL-AHRegister/>

		<cpu:CopyRegisterToOperand/>
		<op:AX-CXRegister/>

		<cpu:CopyRegisterToOperand/>
		<op:AX-BXRegister/>

		<!--Get IP Header Length-->
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:AndAXWithImmediate/>
		<hex>0000000f</hex>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>2</byte>

		<cpu:SubtractRegisterFromOperand/>
		<op:AX-CXRegister/>

		<cpu:AddRegisterToOperand/>
		<op:AX-SIRegister/>

		<!--Get TCP Header Length-->
		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>12</byte>

		<cpu:AndAXWithImmediate/>
		<hex>000000f0</hex>

		<cpu:ShiftRegisterByImmediateFunction8/>
		<shift:ShiftALRegisterRight/>
		<byte>2</byte>

		<cpu:SubtractRegisterFromOperand/>
		<op:AX-CXRegister/>

		<cpu:CopyRegisterToOperand/>
		<op:CX-AXRegister/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetMessage" type="http://metalx.org/String">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:MathImmediate8ToOperandFunction/>
		<math:AddToSIRegister/>
		<byte>14</byte>

		<!--Get IP Length-->
		<cpu:CopyImmediateToAX/>
		<int>0</int>

		<cpu:Operand16/>
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddressPlusImmediate8/>
		<byte>2</byte>

		<cpu:ExchangeOperandWithRegister8/>
		<op:AL-AHRegister/>

		<cpu:CopyRegisterToOperand/>
		<op:AX-CXRegister/>

		<cpu:CopyRegisterToOperand/>
		<op:AX-BXRegister/>

		<!--Get IP Header Length-->
		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:AndAXWithImmediate/>
		<hex>0000000f</hex>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftAXRegisterLeft/>
		<byte>2</byte>

		<cpu:SubtractRegisterFromOperand/>
		<op:AX-CXRegister/>

		<cpu:AddRegisterToOperand/>
		<op:AX-SIRegister/>

		<!--Get TCP Header Length-->
		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>12</byte>

		<cpu:AndAXWithImmediate/>
		<hex>000000f0</hex>

		<cpu:ShiftRegisterByImmediateFunction8/>
		<shift:ShiftALRegisterRight/>
		<byte>2</byte>
		
		<cpu:SubtractRegisterFromOperand/>
		<op:AX-CXRegister/>

		<cpu:AddRegisterToOperand/>
		<op:AX-SIRegister/>

		<cpu:CopyRegisterToOperand/>
		<op:CX-AXRegister/>

		<cpu:AddImmediateToAX/>
		<int>4</int>

		<mm:CheckOut/>

		<cpu:PushDIToStack/>

		<cpu:CopyRegisterToOperand/>
		<op:CX-AXRegister/>

		<cpu:CopyAXToDIAddressAndIncrementDI/>

		<cpu:CompareAXToImmediate/>
		<int>0</int>

		<cpu:BranchToRelative8IfEqual/>
		<addressOf ref="empty" type="Relative8"/>

		<cpu:Repeat/>
		<cpu:CopySIAddressToDIAddressAndIncrementSIAndDI8/>

		<label id="empty"/>

		<cpu:PullDIFromStack/>

		<str:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToString" type="http://metalx.org/String">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetType/>

		<clsf:GetName/>

		<cpu:CopyRegisterToOperand/>
		<op:SI-DIRegister/>

		<str:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetType/>

		<cpu:CopyRegisterToOperand/>
		<op:SI-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class" static="true">
		<cpu:CopyRegisterToOperand/>
		<op:BX-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>
</cls:class>